package com.heima.wemedia.controller.v1;
import com.heima.common.constants.wemedia.WemediaConstants;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDTO;
import com.heima.wemedia.service.WmMaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@Api(value = "素材管理API",tags = "素材管理API")
@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {
    @Autowired
    private WmMaterialService materialService;
    @ApiOperation("上传素材")
    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile) {
        return materialService.uploadPicture(multipartFile);
    }

    @ApiOperation("查询素材")
    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmMaterialDTO dto){
        return materialService.findList(dto);
    }
    @ApiOperation("删除素材")
    @GetMapping("del_picture/{id}")
    public ResponseResult deleteFile(@PathVariable("id") Integer id){
        return materialService.deleteFile(id);
    }
    @ApiOperation("状态更改")
    @GetMapping("collect/{id}")
    public ResponseResult updateStatus(@PathVariable("id") Integer id){
        return materialService.updateStatus(id, WemediaConstants.COLLECT_MATERIAL);
    }
    @GetMapping("cancel_collect/{id}")
    public ResponseResult removeStatus(@PathVariable("id") Integer id){
        return materialService.updateStatus(id,WemediaConstants.CANCEL_COLLECT_MATERIAL);
    }
}